<script lang="ts">
import { defineComponent } from "vue";
import { AppData } from "@/utils/app";

export default defineComponent({
  props: {
    top: String,
    customNav: Boolean,
    background: { type: String, default: "#ffffff" },
  },
  setup(props) {
    return {
      stickyTop:
        props.top || props.customNav ? `${AppData.rectData.topBarHeight}px` : 0,
    };
  },
});
</script>

<template>
  <view class="page-sticky" :style="{ top: stickyTop, background }">
    <slot />
  </view>
</template>

<style lang="scss">
.page-sticky {
  position: sticky;
  top: 0;
  z-index: 8;
}
</style>